package javatwo.annotation.course2.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

@WebListener
public class LogListener implements HttpSessionListener {

	private int onlineUsersCount = 0; 
	
	@Override
	public void sessionCreated(HttpSessionEvent se) {
		System.out.println("new user come in");
		onlineUsersCount ++;
		System.out.println("OnlineUsersCount:"+onlineUsersCount+" " );
		
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		System.out.println("the user leaves");
		onlineUsersCount ++;
		System.out.println("OnlineUsersCount:"+onlineUsersCount+" " );
	}
	


}
